package dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;

import model.Station;

@Stateless
public class StationDAO extends GenericDAO<Station> {
	
	public Station findByName(String stationName) {
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("stationName", stationName);
		List<Station> station = super.findManyResults(Station.FIND_BY_NAME, parameters);
		if (station != null) {
			if (station.isEmpty()) {
				return null;
			} else {
				return station.get(0);
			}
		} else {
			return null;
		}
	}
	
	public StationDAO() {
		super(Station.class);
	}
}
